#include "enemy.h"

#include <stdlib.h>
#include <time.h>

#define SIMPLE_ENEMEY_NAME			"simple_enemy"
#define SIMPLE_ENEMEY_COMMON		"common"
#define SIMPLE_ENEMEY_RANDOM		"random"
#define SIMPLE_ENEMEY_COMMON_HP		100
#define SIMPLE_ENEMEY_RANDOM_HP		150

#ifndef ENEMY_RAND	//ENEMY_RAND(num)  num > 0	;  return 1 ~ num
#define ENEMY_RAND(num) rand()%(num) + 1
#endif

RPG_Object* Simple_Enemey::randomCreate()
{
	RPG_Object* obj = new RPG_Object();
	obj->setName(SIMPLE_ENEMEY_NAME);
	obj->setDescription(SIMPLE_ENEMEY_RANDOM);
	obj->setHpMp(SIMPLE_ENEMEY_RANDOM_HP,0);

	srand((unsigned int)time(NULL)); //use current time as seed for random generator
	obj->setElement(ENEMY_RAND(5),ENEMY_RAND(5),ENEMY_RAND(5),ENEMY_RAND(5));
	obj->setAttackAndDefense(ENEMY_RAND(5),ENEMY_RAND(3));
	return obj;
}

RPG_Object* Simple_Enemey::create()
{
	RPG_Object* obj = new RPG_Object();
	obj->setName(SIMPLE_ENEMEY_NAME);
	obj->setDescription(SIMPLE_ENEMEY_COMMON);
	obj->setHpMp(SIMPLE_ENEMEY_COMMON_HP,0);
	obj->setElement(1,1,1,1);
	obj->setAttackAndDefense(2,1);
	return obj;
}
#undef ENEMY_RAND